package com.yc.favorite.util;

import com.yc.favorite.biz.BizException;

import java.util.Collection;
import java.util.Map;

public class Utils {

    // 判断空对象, 空字符串, 空集合 ...
    public static void checkEmpty(Object object, String msg) throws BizException {
        if(object == null){
            throw new BizException(msg);
        }
        if(object instanceof String){
            String string = (String) object;
            if(string.trim().isEmpty()){
                throw new BizException(msg);
            }
        }
        if(object instanceof Collection){
            Collection collection = (Collection) object;
            if(collection.isEmpty()){
                throw new BizException(msg);
            }
        }
        if(object instanceof Map){
            Map map = (Map) object;
            if(map.isEmpty()){
                throw new BizException(msg);
            }
        }
    }
}
